Add launch metadata for runs#343
Open
mezz wants to merge 1 commit into
Open
Conversation
## Context
JEI needs client tests that can start external dedicated servers.
Today, doing that from another project means reading MDG generated classpath, VM args, and program args files directly. That works, but it depends on internal `build/moddev` file names and requires downstream code to know how MDG assembles a launch command.
## Changes
This change adds a public `CreateLaunchMetadata` task for each configured run.
For a run named `server`, MDG registers:
```groovy
createServerLaunchMetadata
```
The task writes:
```text
build/moddev/serverLaunchMetadata.properties
```
The properties file contains:
- `workingDirectory`
- `javaExecutable`
- `classpathArgsFile`
- `vmArgsFile`
- `programArgsFile`
- `mainClass`
- `modFolders`
- `environment.<name>` entries for run environment variables
There is also a `createLaunchMetadata` aggregate task.
The metadata writer uses the JDK Properties format so consumers can load it with standard properties readers, while MDG keeps the output sorted and comment-free for stable task output.
Launchers should treat `workingDirectory` as part of the metadata contract. If they need disposable or test-specific state, they should configure the run `gameDirectory` instead of replacing the metadata working directory at launch time.
This also adds Gradle daemon JVM criteria for Java 17 so local wrapper invocations use a supported JVM by default.
## Why
This gives consumers like JEI a typed Gradle task output to depend on:
```groovy
tasks.named("createServerLaunchMetadata", CreateLaunchMetadata).flatMap {
it.metadataFile
}
```
Downstream builds can use the metadata without reconstructing MDG launch details from internal file naming conventions.
## Validation
- `./gradlew test --tests net.neoforged.moddevgradle.tasks.CreateLaunchMetadataTest`
- `./gradlew test --tests net.neoforged.moddevgradle.functional.LaunchMetadataFunctionalTest`
- `./gradlew javaImmaculateCheck`
JEI validated this branch with `--include-build ../ModDevGradle`:
- `:NeoForge:runClientRecipeSyncTest`
- NeoForge external server with JEI passed
- NeoForge external server without JEI passed
- vanilla external server without JEI passed
JEI configures each external server run with a JEI-owned build directory as `gameDirectory`, consumes `CreateLaunchMetadata`, and launches using the metadata `workingDirectory` unchanged.
Coverage includes:
- per-run metadata
- the `createLaunchMetadata` aggregate task
- generated arg-file paths
- properties escaping and ordering
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
JEI needs client tests that can start external dedicated servers.
Today, doing that from another project means reading MDG generated classpath, VM args, and program args files directly. That works, but it depends on internal
build/moddevfile names and requires downstream code to know how MDG assembles a launch command.Changes
This change adds a public
CreateLaunchMetadatatask for each configured run.For a run named
server, MDG registers:The task writes:
The properties file contains:
workingDirectoryjavaExecutableclasspathArgsFilevmArgsFileprogramArgsFilemainClassmodFoldersenvironment.<name>entries for run environment variablesThere is also a
createLaunchMetadataaggregate task.The metadata writer uses the JDK Properties format so consumers can load it with standard properties readers, while MDG keeps the output sorted and comment-free for stable task output.
Launchers should treat
workingDirectoryas part of the metadata contract. If they need disposable or test-specific state, they should configure the rungameDirectoryinstead of replacing the metadata working directory at launch time.This also adds Gradle daemon JVM criteria for Java 17 so local wrapper invocations use a supported JVM by default.
Why
This gives consumers like JEI a typed Gradle task output to depend on:
Downstream builds can use the metadata without reconstructing MDG launch details from internal file naming conventions.
Validation
./gradlew test --tests net.neoforged.moddevgradle.tasks.CreateLaunchMetadataTest./gradlew test --tests net.neoforged.moddevgradle.functional.LaunchMetadataFunctionalTest./gradlew javaImmaculateCheckI validated this branch locally using JEI with
--include-build ../ModDevGradle. After simplifying some code there, I was able to successfully run my tests::NeoForge:runClientRecipeSyncTestJEI configures each external server run with a JEI-owned build directory as
gameDirectory, consumesCreateLaunchMetadata, and launches using the metadataworkingDirectoryunchanged.Coverage includes:
createLaunchMetadataaggregate task